﻿using Microsoft.Extensions.DependencyInjection;
using Qianke.Core.Saas.WebApi.SaasExtensions.SaasAduthentication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;

namespace Qianke.Core.Saas.WebApi.SaasExtensions
{
    public static class AuthenticationExtensions
    {
        public static void AddSaasAuthentication(this IServiceCollection services)
        {
            //配置认证机制

            services.AddAuthentication("SAASTOKEN")
                .AddScheme<SaasTokenOptions, SaasTokenHandler>("SAASTOKEN", options => { });
            //配置授权机制
            services.AddAuthorizationBuilder()
                  .AddPolicy("MastLogin", policy => policy.RequireClaim(ClaimTypes.NameIdentifier));
        }
    }
}
